<template>
    <Mapbox :mapOnLoadCB="mapOnLoadCB"></Mapbox>
</template>

<script>
import {ref} from "vue"
import Mapbox from "@/components/common/Mapbox.component.vue"
import {cities} from "@/data/jumpCities"

export default {
    name: "MapJump.component",
    components: {Mapbox},
    setup() {

        let mapStore = ref({});
        let mapOnLoadCB = (map) => {
            mapStore.value = map;

            // 使用 jumpTo function 来展示多个地点。
            cities.features.forEach(function (city, index) {
                setTimeout(function () {
                    map.jumpTo({center: city.geometry.coordinates});
                }, 5000 * index);
            });
        };

        return {
            mapOnLoadCB
        }
    }
}
</script>

<style scoped>

</style>